<template>
  <div class="login-container">
    <div class="login-box">
      <div class="login-left">
        <h2>后台管理系统</h2>
        <p>Professional Admin System</p>
      </div>
      <div class="login-form">
        <h3>系统登录</h3>
        <el-form :model="loginForm" @submit.prevent="handleSubmit">
          <el-form-item prop="username" :rules="[{ required: true, message: '请输入用户名' }]">
            <el-input 
              v-model="loginForm.username" 
              placeholder="用户名"
              :prefix-icon="User"
              class="custom-input"
            />
          </el-form-item>
          <el-form-item prop="password" :rules="[{ required: true, message: '请输入密码' }]">
            <el-input 
              v-model="loginForm.password" 
              type="password" 
              placeholder="密码"
              :prefix-icon="Lock"
              class="custom-input"
            />
          </el-form-item>
          <el-form-item>
            <el-button 
              type="primary" 
              :loading="loading" 
              class="login-button"
              @click="handleSubmit"
            >
              登录系统
            </el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { User, Lock } from '@element-plus/icons-vue'

const router = useRouter()
const loading = ref(false)
const loginForm = reactive({
  username: '',
  password: ''
})

const handleSubmit = async () => {
  loading.value = true
  try {
    // 这里添加实际的登录逻辑
    console.log('登录信息:', loginForm)
    localStorage.setItem('token', 'dummy-token')
    router.push('/dashboard')
  } catch (error) {
    ElMessage.error('登录失败')
  } finally {
    loading.value = false
  }
}
</script>

<style scoped>
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(
    -45deg,
    #ee7752,
    #e73c7e,
    #23a6d5,
    #23d5ab
  );
  background-size: 400% 400%;
  animation: gradient 15s ease infinite;
  position: relative;
  overflow: hidden;
}

/* 添加动态渐变动画 */
@keyframes gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* 添加浮动粒子效果 */
.login-container::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    transparent,
    rgba(255, 255, 255, 0.1) 1px,
    transparent 1px
  ),
  linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1) 1px,
    transparent 1px
  );
  background-size: 30px 30px;
  animation: float 15s linear infinite;
  opacity: 0.2;
}

@keyframes float {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(-30px, -30px);
  }
}

.login-box {
  display: flex;
  width: 900px;
  height: 500px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: boxFloat 6s ease-in-out infinite;
}

@keyframes boxFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.login-left {
  flex: 1;
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
  color: white;
  position: relative;
  overflow: hidden;
}

.login-left::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.1) 40%,
    rgba(255, 255, 255, 0.1) 60%,
    transparent 70%
  );
  animation: shine 4s linear infinite;
}

@keyframes shine {
  0% {
    transform: rotate(0) translate(-50%, -50%);
  }
  100% {
    transform: rotate(360deg) translate(-50%, -50%);
  }
}

.login-left h2 {
  font-size: 36px;
  margin-bottom: 16px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.login-left p {
  font-size: 18px;
  opacity: 0.8;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.login-form {
  flex: 1;
  padding: 40px;
  background: white;
  position: relative;
  z-index: 1;
}

.login-form h3 {
  font-size: 24px;
  color: #2c3e50;
  margin-bottom: 30px;
  text-align: center;
}

.custom-input :deep(.el-input__wrapper) {
  background: #f8f9fa;
  border: none;
  box-shadow: none;
  height: 45px;
  transition: all 0.3s ease;
}

.custom-input :deep(.el-input__wrapper.is-focus) {
  box-shadow: 0 0 0 1px #409eff;
  transform: translateY(-2px);
}

.login-button {
  width: 100%;
  height: 45px;
  border-radius: 4px;
  font-size: 16px;
  background: linear-gradient(45deg, #3498db, #2980b9);
  background-size: 200% 200%;
  border: none;
  margin-top: 20px;
  transition: all 0.3s ease;
  animation: buttonGradient 3s ease infinite;
}

.login-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

@keyframes buttonGradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}
</style> 